package gui.tests;

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

import gui.UndoableTextArea;

@SuppressWarnings("serial")
public class UndoableTester extends JFrame {
	private UndoableTextArea area;
	private JButton undo, redo;
	
	public UndoableTester() {
		area = new UndoableTextArea();
		getContentPane().setLayout(new BorderLayout());
		getContentPane().add(area, BorderLayout.CENTER);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(400, 400);
		
		JPanel buttons = new JPanel();
		buttons.setLayout(new FlowLayout());
		
		undo = new JButton("Undo");
		undo.addActionListener(new Undoer());
		redo = new JButton("Redo");
		redo.addActionListener(new Redoer());
		
		buttons.add(undo);
		buttons.add(redo);
		
		getContentPane().add(buttons, BorderLayout.NORTH);
	}
	
	private class Undoer implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			area.undo();
		}
 	}
	
	private class Redoer implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			area.redo();
		}
	}
	
	public static void main(String[] args) {
		new UndoableTester().setVisible(true);
	}
}
